<template>
  <div>
    <!--公用 数量选择组件 -->
     <div class="mui-numbox" data-numbox-min="1" >
      <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
      <input id="test" class="mui-input-numbox" type="number" ref="numbox" :value="initnum" @change="numchange">
      <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
  </div>
</template>
<script>
import mui from '../../lib/mui/js/mui.min.js'
export default {
  data() {
    return {
     
    };
  },
 props:['goodsId','initnum'],
  watch: {
      
   },
  methods:{
    //  监听文本框值的变化
    numchange(){
      // var id = this.goodsId;
      // var count = this.$refs.numbox.value;
      this.$store.commit('upData',{id:this.goodsId,count:this.$refs.numbox.value})
    }
  },
  mounted(){
    // 初始化手动增加和减少
    mui('.mui-numbox').numbox()
  }
}
</script>
<style lang="css" scoped>
   .mui-numbox{
        height:30px;
    }
</style>